/**
 * @file   1083.cpp
 * @author Shuang Hu <hsmath@ubuntu>
 * @date   Fri Jul 30 20:04:35 2021
 * 
 * @brief  PAT advanced:1083
 * 
 * 
 */
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
class stu{
public:
    string name;
    string ID;
    int grade;
};
class Solution{
private:
    vector<stu> candidates;
    int low;
    int high;
    int stunum;
public:
    Solution();
    void Solve();
};
bool cmp(stu& S1,stu& S2){
    return (S1.grade>S2.grade);
}
Solution::Solution(){
    cin>>stunum;
    for(int i=0;i<stunum;i++){
	stu S;
	cin>>S.name>>S.ID>>S.grade;
	candidates.push_back(S);
    }
    cin>>low>>high;
    sort(candidates.begin(),candidates.end(),cmp);
}
void Solution::Solve(){
    bool exist=false;
    for(int i=0;i<candidates.size();i++){
	if(candidates[i].grade<low){
	    break;
	}else if(candidates[i].grade<=high){
	    exist=true;
	    cout<<candidates[i].name<<" "<<candidates[i].ID<<endl;
	}
    }
    if(exist==false){
	cout<<"NONE"<<endl;
    }
}
int main(){
    Solution S;
    S.Solve();
}
